package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * 仙剑奇侠
 *
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(38)
public class XianjianqixiaGameStrategy extends BaseGameStrategy {

    public static final String PAY = "http://110.40.83.197:40698/gm/gm/pay";
    public static final String MAIL = "http://110.40.83.197:40698/gm/gm/item";

    /**
     * userid: 风云精品
     * paytype: 3
     * paynum: 112211
     *
     * @param item
     * @return
     */
    @GongnengMethod(3801)
    public String pay(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();

        params.add("userid", item.uid);
        params.add("paynum", item.number);
        params.add("paytype", item.itemId);

        return RestTemplateUtil.sendPostFormAndGetJsonKey(PAY, params,"msg");
    }

    /**
     * userid: 风云精品
     * item: 100011
     * itemnum: 2
     *
     * @param item
     * @return
     */
    @GongnengMethod(3802)
    public String mail(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();

        params.add("userid", item.uid);
        params.add("itemnum", item.number);
        params.add("item", item.itemId);

        return RestTemplateUtil.sendPostFormAndGetJsonKey(MAIL, params,"msg");
    }



    @GongnengMethod(9)
    public String clear(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }

    public static void main(String[] args) {
        SendItem item = new SendItem();
        item.uid = "10000000001";
        item.number = "121";
        item.itemId = "1,19";
        System.out.println(new XianjianqixiaGameStrategy().mail(item));
    }
}

